<?php
	$url = explode('.', $_SERVER['SERVER_NAME']);
	if ( !empty($_COOKIE['def_area']) && !strstr($_SERVER["REQUEST_URI"],'default.php') ){
		header("Location: http://{$_COOKIE['def_area']}.ttday.com/forum.php");
	}
	
	if ( count($url) == 3 && $url[0] != 'www' ){
		setcookie("def_area", $url[0], time()+3600*24*30, "/", ".ttday.com");
		header("Location: http://{$url[0]}.ttday.com/forum.php");
	}
		
	include './config/config_global.php';
	include './config/mysql.php';
	include './config/mysql_func.php';
	
	include './lib/function.php';
	$re_areas = getarea();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="天天网,生活社区,生活门户">
<meta name="description" content="天天网是中国最大的生活门户，是基于本地社区的互联网生活服务平台。">
<title>天天网-中国最大的个人生活门户</title>
<link href="static/css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="static/js/Ajax.js"></script>
</head>
<body>
<center>
  <div id="guide">
    <div id="guide_logo"><img src="static/image/ttday/logo.gif" /></div>
    <div id="guide_kouhao"><img src="static/image/ttday/kouhao.gif" /></div>
    <div id="guide_text"> 天天网是一个完全免费的本地生活社区网站，<a href="member.php?mod=register">注册</a>成为天天用户，<br />
      你可以联系同一区域的人，分享生活资讯、讨论生活话题，找到同乡好友，参与线下活动。 </div>
  </div>

	<div id="recommand_area">
	  <div id="recommandCity">
	  	<b>选择<?php if ( !empty( $re_areas ) ) {list( ,$name ) = explode(' ',$re_areas[0]['name']); echo $name; unset($re_areas[0]);}?>区域 <img src="static/image/ttday/arrows.jpg" /></b>
	  </div>
	  <div id="rcity">
	  	<?php foreach( (array)$re_areas as $re_area ):?>
	    <a href="http://<?=$re_area['url_short']?>.ttday.com/"><?php list( ,$name ) = explode(' ',$re_area['name']); echo $name;?></a>
		<?php endforeach;?>
	  </div>
	</div>

  <div id="select_area">
    <div id="select_enter">
      <form id="form1" name="form1" method="post" action="" onsubmit="return jumpUrl();">
        <b>选择区域 <img src="static/image/ttday/arrows.gif" /></b> <span id="sprovince">
        <select id="province" onchange="getOption(this.value);">
          <option value="-1" selected>省份</option>
          <?php
					$sql="select * from pre_common_district where level=1 order by name";
					
					$result=mysql_query($sql);
					while($row=mysql_fetch_row($result)){
					  echo "<option value='$row[0]'>$row[1]</option>";
					}
				?>
        </select>
        </span> <span id="scity">
        <select id="city">
          <option value="-1" selected>城市</option>
        </select>
        </span> <span id="sarea">
        <select id="area">
          <option value="-1" selected>请选择区域</option>
        </select>
        </span>
        <input type="submit" name="queding" value="确定" class="queding_btn" style="vertical-align:top;"/>
      </form>
    </div>
    <div id="input_enter">
      <form id="form2" name="form2" method="post" action="">
        <b>或者</b>
        <input type="text" id="area_text" name="area_text" value="区域名称、拼音首字母或全拼" class="enter_txt" onblur="if(this.value=='')this.value='区域名称、拼音首字母或全拼';" onfocus="if(this.value=='区域名称、拼音首字母或全拼')this.value='';" onkeyup="getAreaName(this.value);" style="height:22px;line-height:22px;" />
        <div id="result" style="display:none;"></div>
        <input type="hidden" name="area_short" value="" />
        <a href="javascript:void(0);" onclick="return goUrl();" style="height:20px;line-height:20px;" >进入区域</a>
      </form>
    </div>
    <div style="clear: both;"></div>
    <div style="margin: 0px 0px 5px 70px; width: 230px; color: red;display:none;" id="tip">请选择生活区域,再确定</div>
  </div>
  <div id="seek_area">
  	<div style="width:964px;height:30px;margin-bottom:10px;">
	<b>按区域快速查找</b><span style="color:red;">(点击城市可以显示区县)</span>
    </div>
	<?php
		$arr=array(1=>"直辖市",2=>"华东地区",3=>"华南华中",4=>"华北东北",5=>"西部地区");
		for($i=1;$i<=5;$i++)
		{
			echo "<div style='width:964px;clear:both;'><span class='district_css'>".$arr[$i]."</span></div>";
			
			$sql1="select * from pre_common_province where areatype=".$i;
			$result1=mysql_query($sql1);
			
			echo "<div style='width:964px;height:auto;margin-bottom:10px;'>";
			
			while($row1=mysql_fetch_row($result1))
			{
			 echo "<div class='district'><dl>";
			 echo "<dt style='margin-right:8px;'><b>".substr($row1[1],2)."</b></dt>";
			 
			 if($i==1)
			 {
			 	echo "<dd>";
				$sql5="select * from pre_common_district where level=2 and name='".$row1[1]."'";		
				$result5=mysql_query($sql5);
				while($row5=mysql_fetch_row($result5)){
					$sql6="select * from pre_common_district where level=3 and upid=".$row5[0];
					$result6=mysql_query($sql6);
					while($row6=mysql_fetch_row($result6)){
						echo "<a href='http://". $row6[8] .".ttday.com/'>".substr($row6[1],2)."</a>";
					}
			  	}
				echo "</dd>";
			 }
			 else
			 {
			  echo "<dd>";
			  $sql2="select * from pre_common_district where level=1 and name='".$row1[1]."'";
			  $result2=mysql_query($sql2);
			  while($row2=mysql_fetch_row($result2))
			  {
					$sql3="select * from pre_common_district where level=2 and upid=".$row2[0];		
					$result3=mysql_query($sql3);
					while($row3=mysql_fetch_row($result3))
					{
						//echo $row3[0];
						$sql4="select * from pre_common_district where level=3 and upid=".$row3[0];		
						$result4=mysql_query($sql4);
						$num=mysql_num_rows($result4);
						if($num>1)
						{
							echo "<a id='link_". $row3[0] ."' href='javascript:void(0);' onclick='showSub(event,". $row3[0] .");'>".substr($row3[1],2)."</a>";
							echo "<div id='div_". $row3[0] ."' style='display:none;z-index:2;border:1px solid #66ccaa;'>";
							$the_link="";
							while($row4=mysql_fetch_row($result4))
							{
								//echo $row4[0];
								$the_link=$the_link."<a href='http://". $row4[8] .".ttday.com'>".substr($row4[1],2)."</a>";
							}
							$the_link=$the_link."<a href='javascript:void(0);' onclick='closeDiv(". $row3[0] .");' style='color:#A2A2A2;font-weight:bold;'>关闭</a>";
							echo $the_link;
							echo "</div>";
						}
						else
						{
							echo "<a href='http://". $row3[8] .".ttday.com'>".substr($row3[1],2)."</a>";
						}		
					}
			  }
			  echo "</dd>";	  
			 }
			//echo "<br />";		 
			 echo "</dl></div>";
			 
			}
			echo "</div>";
			echo "<div id='blank_div'></div>";
			//echo "<br />";
		}
	?>
  </div>
  <div id="bottom">
  	<div id="left_bottom">
	<div id="l_btm">
	<ul>
		<li><a href="#">关于我们</a></li>
		<li>|</li>
		<li><a href="#">招聘信息</a></li>
		<li>|</li>
		<li><a href="#">免责条款</a></li>
		<li>|</li>
		<li><a href="#">联系我们</a></li>
		<li>|</li>
		<li><a href="#">网站地图</a></li>
	</ul>
	<span>
		Copyright&copy;2011 ttday.com All Rights Reserved 天天网
	</span>
	</div>
	</div>
	<div id="right_bottom">
		<img src="static/image/ttday/wangjing.gif" />
	</div>
  </div>
</center>
</body>
</html>